﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Inaction.Core;
using Inaction.Mapping;

namespace Inaction.Business.Security.Abstract
{
    [Table("Department"), DisplayName("部门"), Serializable]
    public abstract class Department<T> : Inaction.Business.Entity<T> where T : Department<T>, new()
    {
        #region 属性

        public static readonly Property<Guid?> IdProperty = RegisteProperty<Guid?>(p => p.Id);
        Guid? _id;
        [Column("Id"), DisplayName("部门"), Display(Description = "部门")]
        public Guid? Id
        {
            get { return _id; }
            internal set { SetProperty(IdProperty, ref _id, value); }
        }

        public static readonly Property<String> NameProperty = RegisteProperty<String>(p => p.Name);
        String _name;
        [Column("Name"), DisplayName("名称"), Display(Description = "名称")]
        public String Name
        {
            get { return _name; }
            set { SetProperty(NameProperty, ref _name, value); }
        }

        public static readonly Property<String> CodeProperty = RegisteProperty<String>(p => p.Code);
        String _code;
        [Column("Code"), DisplayName("编号"), Display(Description = "编号")]
        public String Code
        {
            get { return _code; }
            set { SetProperty(CodeProperty, ref _code, value); }
        }

        public static readonly Property<Guid?> ParentDepartmentIdProperty = RegisteProperty<Guid?>(p => p.ParentDepartmentId);
        Guid? _parentDepartmentId;
        [Column("ParentDepartmentId"), DisplayName("上级部门"), Display(Description = "上级部门")]
        public Guid? ParentDepartmentId
        {
            get { return _parentDepartmentId; }
            set { SetProperty(ParentDepartmentIdProperty, ref _parentDepartmentId, value); }
        }


        public static readonly Property<String> CreaterProperty = RegisteProperty<String>(p => p.Creater);
        String _creater;
        [Column("Creater"), DisplayName("创建人"), Display(Description = "创建人"), Browsable(false)]
        public String Creater
        {
            get { return _creater; }
        }

        public static readonly Property<DateTime?> CreateTimeProperty = RegisteProperty<DateTime?>(p => p.CreateTime);
        DateTime? _createTime;
        [Column("CreateTime"), DisplayName("创建时间"), Display(Description = "创建时间"), Browsable(false)]
        public DateTime? CreateTime
        {
            get { return _createTime; }
        }

        public static readonly Property<String> UpdaterProperty = RegisteProperty<String>(p => p.Updater);
        String _updater;
        [Column("Updater"), DisplayName("修改人"), Display(Description = "修改人"), Browsable(false)]
        public String Updater
        {
            get { return _updater; }
        }

        public static readonly Property<DateTime?> UpdateTimeProperty = RegisteProperty<DateTime?>(p => p.UpdateTime);
        DateTime? _updateTime;
        [Column("UpdateTime"), DisplayName("修改时间"), Display(Description = "修改时间"), Browsable(false)]
        public DateTime? UpdateTime
        {
            get { return _updateTime; }
        }

        public static readonly Property<Boolean?> DeletedProperty = RegisteProperty<Boolean?>(p => p.Deleted);
        Boolean? _deleted;
        [Column("Deleted"), DisplayName(""), Display(Description = ""), Browsable(false)]
        public Boolean? Deleted
        {
            get { return _deleted; }
        }

        #endregion
    }
}
